﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Character.Jarily {
    [RequireComponent(typeof(Collider2D))]
    [RequireComponent(typeof(Rigidbody2D))]
    public class Physicalprojectile : MonoBehaviour {
        [SerializeField]
        RemoteAttackMode mode = RemoteAttackMode.KineticWeapon;
        internal float rotation = 0f;
        [SerializeField]
        internal float initialvelocity = 0f;
        [SerializeField]
        //[Range(0, 10)]
        //int attackValue = 0;
        bool right = false;

        internal void SetRight(bool right) {
            this.right = right;
        }
        private void OnEnable() {
            Rigidbody2D rigi = GetComponent<Rigidbody2D>();
            Collider2D collider = GetComponent<Collider2D>();
            collider.isTrigger = true;
            rigi.velocity = (right ? Quaternion.Euler(0, 0, rotation) : Quaternion.Euler(0, 180, rotation)) * Vector2.right * initialvelocity;
            rigi.bodyType = mode == RemoteAttackMode.Ray ? RigidbodyType2D.Kinematic : RigidbodyType2D.Dynamic;
        }
    }
}



